kind: pipeline
type: docker
name: default

steps:
- name: build
  image: bretfisher/jekyll
  commands:
  - cd src
  # To fix "There was an error while trying to write to .../Gemfile.lock" and
  # avoid changes in this file to be included in commit
  - echo 'src/Gemfile.lock' >> ../.git/info/exclude
  - test -e Gemfile.lock && chmod a+w Gemfile.lock
  # Setup environment
  - bundle
  # To fix write issues
  - mkdir _site; mkdir .jekyll-cache
  # Run build
  - jekyll build
  # Prep a list of generated files for cleanup later + do cleanup
  - cd _site
  - find . -print > file_list ; sed -i '/^.$/d' file_list
  - cd ../../
  - test -e file_list && while IFS= read -r file ; do rm -rf "$file" ; done < file_list
  - cd src
  # Move site files to repo root
  - mv _site/* ../
  - cd ..

- name: push commit
  image: appleboy/drone-git-push
  settings:
    branch: main
    remote: git@codeberg.org:jekyll-test/pages.git
    force: false
    commit: true
    commit_message: "Drone build ${DRONE_COMMIT_SHA:0:7}"
    author_name: "John Doe"
    author_email: "example@email.com"
    ssh_key:
      from_secret: ssh_key

